﻿package org.display.util
{
	import flash.filesystem.File;
	import flash.utils.*;
	
	import org.abcFrame.core.*;
	import org.data.*;
	import org.display.graphic.*;
	import org.enmu.*;
	import org.events.*;
	import org.net.*;
	import org.utils.*;
	
	public class CreateAllClass
	{

		var publicfiles:Array=[]
			
		public function CreateAllClass(scene,tab)
		{
			var xmlFile:File=File.documentsDirectory.resolvePath((Global.workspace+"\\xml").replace(/\\/gis,"/"))
			
			if(xmlFile.exists == false){return;}	
			
			createClass(xmlFile,scene,tab)
			
			
		}

		function createClass(file,scene,tab){
			
			var num=0
			
			var files:Array=file.getDirectoryListing() 
				
			for(var i=0;i<files.length;i++){
				
				if(files[i].isDirectory){
					
					createClass(files[i],scene,tab)
					
				}else{
					
					var path:String=files[i].url.replace(/file:\/\/\//gis,"")
					
					var xmlRes:AbcResponder=new AbcResponder()
					xmlRes.onResult=function(e,path){
						
						Global.classType_jsfl=String(XML(e).type)

						Global.selectPath=path
						
						Global.xmlPath=path
						
						//锁定路径
						//Global.lockPath=path.replace(/\//gis,"\\").replace(new RegExp(Global.workspace.replace(/\\/gis,"\\\\"),"gis"),"")
							
						Global.lockPath=path.replace(/\//gis,"\\").replace(/.*?(?=org)/gis,"")
							
						var arr:Array=Global.lockPath.split("\\")
						
						arr.pop()
						
						Global.lockPath="\\"+arr.join("\\")
						//trace(Global.lockPath)
						//trace(Global.lockPath)
							
						var iv:Iv=new Iv(path.replace(/\\/gis,"\/"))
						
						setTimeout(
							function(iv,scene,type){
							
							ElementControl.cleanObjByType(ShapeBase,scene)
							
							iv.setObjs(scene)

							var name:String=path.split("/").pop().replace(/View\.xml/gis,"")

							new CreateClass(scene,name,type,Global.lockPath)
							
						    },num+=300,iv,scene,Global.classType_jsfl)
						
					}
					new AbcHTTPServices(path,xmlRes)
						
				}
			}
			
		}

		
	}
}